package base.day26.udp;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class MyInetAddress1 {
    public static void main(String[] args) throws UnknownHostException {
        //确定主机的名称 ，可以是机器名，也可以是ip地址
        InetAddress ia = InetAddress.getByName("SuperJohn");

        //getHostName 获取ip地址的主机名
        String hostName = ia.getHostName();
        System.out.println("主机名为"+hostName);

        //getHostAddress 返回文本显示的ip地址
        String hostAddress = ia.getHostAddress();
        System.out.println("ip地址"+hostAddress);


    }
}
